#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 1e5+10;

int c[N],t[N],dc[N],dt[N],n;

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in; for(int i = 1;i <= n;i++) c[i] = in;
	for(int i = 1;i <= n;i++) t[i] = in;
	if(c[1] != t[1] || c[n] != t[n]) return puts("No"),0;
	for(int i = 1;i <= n;i++) dc[i] = c[i] - c[i-1];
	for(int i = 1;i <= n;i++) dt[i] = t[i] - t[i-1];
	sort(dc+1,dc+n+1); sort(dt+1,dt+n+1);
	for(int i = 1;i <= n;i++) if(dc[i] ^ dt[i]) return puts("No"),0;
	puts("Yes");
	return 0;
}

